<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@ page import="com.scalar.chiptrack.utils.ConfigManager,org.apache.struts.util.LabelValueBean,
                 java.util.ArrayList"%>
<%@ page import="com.scalar.chiptrack.commons.Constants" %>
<%@ page import="com.scalar.chiptrack.jasper.JasperReports" %>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/wipInventoryReport.do?action=inventoryInfoNew" />

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<%
    String userTypeChiptrac = Constants.USER_TYPE_CHIPTRAC + "";
    String baseProcessType = request.getAttribute("baseProcessType") !=null ? (String)request.getAttribute("baseProcessType") : "";
%>
<HTML><HEAD>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script>
var baseProcessName = '<%=baseProcessType%>';

function addOrRemoveOptionToProcessSelectNew ( action , selOption , fromChk)
{
	document.wipInventoryInfo.process.value = '0';
	document.wipInventoryInfo.action="<%=chipTracContext%>/wipInventoryReport.do?action=inventoryInfoNew";
	document.wipInventoryInfo.submit();
}

function validatefields()
{
	var formdoc = document.wipInventoryInfo;
 	var errMsg = '';
	var pa	= document.getElementById("errors");

    var productNameObj = formdoc.productName;

    for( var i = 0 ; i < productNameObj.length; i++ )
    {
        if (productNameObj.options[i].selected)
        {
			if( productNameObj.options[i].value == "-1" || productNameObj.options[i].value == "-2" )
			{
                pa.innerHTML = "Please select valid Part Number";
                return false;
			}
        }
    }

	if( chkDate( formdoc.asOfDate.value,'As of Date','N') == false )
	{
		pa.innerHTML = errMsg;
		formdoc.asOfDate.focus();
		return false;
	}
	pa.innerHTML = errMsg;
    return true;
}

var dateElement = "";

function openCalendar( dateValue )
{
	dateElement = dateValue;
  	newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
  	newWindow.moveTo(550,180);
  	newWindow.focus();
}

function assignDate( passedValue )
{
	dateElement.value=passedValue;
	window.focus();
}

// disable the list to select the process-step from the list when finished goods option is choosen
function Disab()
{
	var len = document.wipInventoryInfo.reportType.length;

    for( var i = 0; i < len; i++ )
	{
		if(	document.wipInventoryInfo.reportType[i].checked )
		{
			var temp = 	document.wipInventoryInfo.reportType[i].value;

			if( temp == 'finished' || temp == 'discrepancy' || temp == 'intransit' )
			{
                document.wipInventoryInfo.productName[0].selected = true;
                document.wipInventoryInfo.productName.disabled = true;

                document.wipInventoryInfo.vendorName[0].selected = true;
                document.wipInventoryInfo.vendorName.disabled = false;

                if( temp == 'discrepancy')
                {
                   // document.wipInventoryInfo.process[0].selected = true;
                    document.wipInventoryInfo.process.disabled = false;

                    document.wipInventoryInfo.category[0].selected = true;
                    document.wipInventoryInfo.category.disabled = true;

                    document.wipInventoryInfo.status[0].selected = true;
                    document.wipInventoryInfo.status.disabled = true;
                }
                else if ( temp == 'finished')
                {
                    document.wipInventoryInfo.process[0].selected = true;
                    document.wipInventoryInfo.process.disabled = true;

                    document.wipInventoryInfo.category[0].selected = true;
                    document.wipInventoryInfo.category.disabled = false;

                     document.wipInventoryInfo.status[0].selected = true;
                    document.wipInventoryInfo.status.disabled = false;
                }
                else
                {
                    //document.wipInventoryInfo.process[0].selected = true;
                    document.wipInventoryInfo.process.disabled = false;

                    document.wipInventoryInfo.category[0].selected = true;
                    document.wipInventoryInfo.category.disabled = true;

                    document.wipInventoryInfo.status[0].selected = true;
                    document.wipInventoryInfo.status.disabled = true;
                }
			}
		}
	}
}

function Enable()
{
	var len = document.wipInventoryInfo.reportType.length;
	for( var i = 0; i < len; i++ )
	{
		if(	document.wipInventoryInfo.reportType[i].checked )
		{
			var temp = 	document.wipInventoryInfo.reportType[i].value;
			if( temp == 'wip' || temp == 'inventory' || temp == 'all' || temp == 'allWithNonValue' )
			{
				document.wipInventoryInfo.process.disabled = false;
                document.wipInventoryInfo.productName.disabled = false;
            }
      	}
	}
}

function getYear( d )
{
  return (d < 1000) ? d + 1900 : d;
}

/*
*
* There was a problem with the CR, if the date entered was of the format (m/d/yyyy) the prompt sent was not recognised by
* CR tool thus I had to append 0 infront of the month before it was sent to the Proc in the CR.
* This function takes care of the aforesaid problem.
*/
function dateCheck()
{
	var date_check = document.wipInventoryInfo.asOfDate.value;
	var pa = document.getElementById("errors");
	if (date_check=='')
		date_check='0';
	else
	{
		var month, date, year;
		var day_check  = date_check.split('/');
		month = day_check[0];
		date = day_check[1];
		year = day_check[2];
		if ( month < 10 )
		{
			if ( month.length == 1 )
				month = "0"+month;
		}

		if ( date < 10 )
		{
			if (date.length == 1)
				date = "0"+date;
		}
		date_check = month+"/"+date+"/"+year;
	}

	var check = date_check.split('/');
	if ( check[0] == '00' )
		date_check = '0';
	if ( date_check!='0' )
	{
		if ( !isDate( year, month, date ) )
		{
			pa.innerHTML="Please enter a valid Date...!";
			date_check = 'InValid';
		}
	}
	return date_check;
}

function submitForm( fileType ) // Here fileType 1 means Crystal Report, 2 means Excel
{
	var cat="";
	var d = new Date();
	var day = d.getDate();
	var month = d.getMonth()+1;
	var year = d.getFullYear();
	var hour = d.getHours();
	var min = d.getMinutes();
	var sec = d.getSeconds();
    var pa	= document.getElementById("errors");
	if ( month < 10 )
		month = "0"+month;
	if ( day < 10 )
		day = "0"+day;
	var today = month+"/"+day+"/"+year;
	var defaultPrompt = day+"/"+month+"/"+year+":"+hour+":"+min+":"+sec;
    var success = true;
    success = validatefields();
    if( document.wipInventoryInfo.asOfDate.value != '' && success == true  )
    {
        var array = (document.wipInventoryInfo.asOfDate.value).split("/");
        if ( array[0] < 10 && array[0].length < 2)
            array[0] = "0"+array[0];
        if ( array[1] < 10 && array[1].length < 2 )
            array[1] = "0"+array[1];
        document.wipInventoryInfo.asOfDate.value = array[0]+"/"+array[1]+"/"+array[2];
    }

    var element = document.wipInventoryInfo.productName;
    var productName = "";
    var count = 0;
    for( var i = 0 ; i < element.length; i++ )
    {
        if (element.options[i].selected)
        {
            count++;
            if ( productName != '')
            {
                productName = productName+","+element.options[i].value;
            }
            else
            {
                productName = element.options[i].value;
            }
        }
    }
    if ( productName == '')
    {
        productName = "0";
    }
    if( count > 10)
    {
        pa.innerHTML = "<li>Please select upto 10 prodcuts only";
		return ;
    }
    else
    {
        for ( var counter = 0; counter < document.wipInventoryInfo.reportType.length; counter++ )
        {
            if ( document.wipInventoryInfo.reportType[counter].checked )
            {
                cat = document.wipInventoryInfo.reportType[counter].value;
            }
        }

        if ( cat == "inventory" )
        {
            document.wipInventoryInfo.prompt0.value=escape(document.wipInventoryInfo.process.value);
            document.wipInventoryInfo.prompt1.value = productName;
            if ( document.wipInventoryInfo.vendorName.value == "All Vendors" || document.wipInventoryInfo.vendorName.value == '' )
            {
                document.wipInventoryInfo.prompt2.value="0";
            }
            else
            {
                document.wipInventoryInfo.prompt2.value= document.wipInventoryInfo.vendorName.value;
            }
            document.wipInventoryInfo.prompt3.value= document.wipInventoryInfo.category.value;
            document.wipInventoryInfo.prompt4.value=document.wipInventoryInfo.asOfDate.value;
            document.wipInventoryInfo.prompt5.value=document.wipInventoryInfo.status.value;
            document.wipInventoryInfo.prompt6.value=cat;
            document.wipInventoryInfo.prompt7.value = document.wipInventoryInfo.search.value;
            document.wipInventoryInfo.prompt8.value= defaultPrompt;

            //var process_type = document.wipInventoryInfo.prompt0.value;

            // Added if the date entered is today then call the default wip inventory report
            if( document.wipInventoryInfo.prompt4.value=='' || document.wipInventoryInfo.prompt4.value == today )
                document.wipInventoryInfo.prompt4.value='0';

            if( baseProcessName == null || baseProcessName == '')
            {
                document.wipInventoryInfo.prompt0.value='INVENTORY';
            }

            if( baseProcessName.toUpperCase() == 'Wafer Store'.toUpperCase()  )
            {
                document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/Inventory_Wafer_Report.rpt";
            }
            else if( baseProcessName.toUpperCase() == 'Die Bank'.toUpperCase() )
            {
                document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/DieBank.rpt";
            }
            else if( baseProcessName.toUpperCase() == 'Class Store'.toUpperCase() )
            {
                document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/ClassStore.rpt";
            }
            else if( baseProcessName.toUpperCase() == 'Finished Goods'.toUpperCase() )
            {
                document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/Finished_Goods.rpt";
            }
            else
            {
                document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/Wip_Inventory.rpt";
            }
        }
        else if ( cat == "wip" )
        {
            document.wipInventoryInfo.prompt0.value=escape(document.wipInventoryInfo.process.value);
            document.wipInventoryInfo.prompt1.value = productName;
            if ( document.wipInventoryInfo.vendorName.value == "All Vendors" || document.wipInventoryInfo.vendorName.value == '' )
            {
                document.wipInventoryInfo.prompt2.value="0";
            }
            else
            {
                document.wipInventoryInfo.prompt2.value= document.wipInventoryInfo.vendorName.value;
            }
            document.wipInventoryInfo.prompt3.value= document.wipInventoryInfo.category.value;
            document.wipInventoryInfo.prompt4.value=document.wipInventoryInfo.asOfDate.value;
            document.wipInventoryInfo.prompt5.value=document.wipInventoryInfo.status.value;
            document.wipInventoryInfo.prompt6.value=cat;
            document.wipInventoryInfo.prompt7.value = document.wipInventoryInfo.search.value;
            document.wipInventoryInfo.prompt8.value= defaultPrompt;

            //var process_type = document.wipInventoryInfo.prompt0.value;

            if( document.wipInventoryInfo.prompt4.value==''|| document.wipInventoryInfo.prompt4.value == today )
                document.wipInventoryInfo.prompt4.value='0';

            if( baseProcessName == null || baseProcessName == '')
            {
                document.wipInventoryInfo.prompt0.value = 'WIP';
            }

           if ( baseProcessName.toUpperCase() == 'Fab'.toUpperCase() )
			{
                document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/Fab_wip.rpt";
            }
            else if ( baseProcessName.toUpperCase() == 'Test'.toUpperCase() )
            {
                document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/wip.rpt";
            }
            else if ( baseProcessName.toUpperCase() == 'Assembly'.toUpperCase() )
            {
                document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/Assembly.rpt";
            }
            else
            {
                document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/wip.rpt";
            }

        }
        else if ( cat == "all" || cat == 'allWithNonValue' )
        {
            document.wipInventoryInfo.prompt0.value=escape(document.wipInventoryInfo.process.value);
            document.wipInventoryInfo.prompt1.value = productName;
            if ( document.wipInventoryInfo.vendorName.value == "All Vendors" || document.wipInventoryInfo.vendorName.value == '' )
            {
                document.wipInventoryInfo.prompt2.value="0";
            }
            else
            {
                document.wipInventoryInfo.prompt2.value= document.wipInventoryInfo.vendorName.value;
            }
            document.wipInventoryInfo.prompt3.value= document.wipInventoryInfo.category.value;
            document.wipInventoryInfo.prompt4.value=document.wipInventoryInfo.asOfDate.value;
            document.wipInventoryInfo.prompt5.value=document.wipInventoryInfo.status.value;
            document.wipInventoryInfo.prompt6.value=cat;
            document.wipInventoryInfo.prompt7.value = document.wipInventoryInfo.search.value;
            document.wipInventoryInfo.prompt8.value= defaultPrompt;

            //var process_type = document.wipInventoryInfo.prompt0.value;

            if( document.wipInventoryInfo.prompt4.value==''|| document.wipInventoryInfo.prompt4.value == today )
                document.wipInventoryInfo.prompt4.value='0';

            if( baseProcessName == null || baseProcessName == '')
            {
                document.wipInventoryInfo.prompt0.value = '0';
            }

            if ( baseProcessName.toUpperCase() == 'Fab'.toUpperCase() )
			{
                document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/Fab_wip.rpt";
            }
            else if ( baseProcessName.toUpperCase() == 'Assembly'.toUpperCase() )
            {
                document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/Assembly.rpt";
            }
            else if ( baseProcessName.toUpperCase() == 'TEST'.toUpperCase() )
            {
                document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/wip.rpt";
            }
            else if( baseProcessName.toUpperCase() == 'Wafer Store'.toUpperCase() )
            {
                document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/Inventory_Wafer_Report.rpt";
            }
            else if( baseProcessName.toUpperCase() == 'Die Bank'.toUpperCase() )
            {
                document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/DieBank.rpt";
            }
            else if( baseProcessName.toUpperCase() == 'Class Store'.toUpperCase() )
            {
                document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/ClassStore.rpt";
            }
            else if( baseProcessName.toUpperCase() == 'Finished Goods'.toUpperCase() )
            {
                document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/Finished_Goods.rpt";
            }
            else
            {
                document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/wip.rpt";
            }

        }
        else if ( cat == "finished" )
        {
            document.wipInventoryInfo.prompt0.value='FG';
            document.wipInventoryInfo.prompt1.value = productName;
            if ( document.wipInventoryInfo.vendorName.value == "All Vendors" || document.wipInventoryInfo.vendorName.value == '' )
            {
                document.wipInventoryInfo.prompt2.value="0";
            }
            else
            {
                document.wipInventoryInfo.prompt2.value= document.wipInventoryInfo.vendorName.value;
            }
            document.wipInventoryInfo.prompt3.value= document.wipInventoryInfo.category.value;
            document.wipInventoryInfo.prompt4.value=document.wipInventoryInfo.asOfDate.value;
            document.wipInventoryInfo.prompt5.value=document.wipInventoryInfo.status.value;
            document.wipInventoryInfo.prompt6.value=cat;
            document.wipInventoryInfo.prompt7.value = document.wipInventoryInfo.search.value;
            document.wipInventoryInfo.prompt8.value= defaultPrompt;

            if( document.wipInventoryInfo.prompt4.value=='' || document.wipInventoryInfo.prompt4.value == today )
                document.wipInventoryInfo.prompt4.value='0';

            document.wipInventoryInfo.action = "<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/Finished_Goods.rpt";
            /*if( success == true )
            {
                document.wipInventoryInfo.submit();
            }*/
        }
        else if ( cat == "intransit" )
        {

            document.wipInventoryInfo.prompt0.value = escape(document.wipInventoryInfo.process.value);
            document.wipInventoryInfo.prompt1.value = '0';
            document.wipInventoryInfo.prompt2.value = '0';
            document.wipInventoryInfo.prompt3.value = document.wipInventoryInfo.vendorName.value;
            document.wipInventoryInfo.prompt4.value = document.wipInventoryInfo.asOfDate.value;
            document.wipInventoryInfo.prompt5.value = '0';
            document.wipInventoryInfo.prompt6.value = document.wipInventoryInfo.search.value;
            document.wipInventoryInfo.prompt7.value = document.wipInventoryInfo.category.value;
            document.wipInventoryInfo.prompt8.value = '0';
            document.wipInventoryInfo.prompt9.value = 'wip';
            document.wipInventoryInfo.prompt10.value = 'Crystal';
            document.wipInventoryInfo.prompt11.value = defaultPrompt;

            if( document.wipInventoryInfo.prompt4.value=='' || document.wipInventoryInfo.prompt4.value == today )
                document.wipInventoryInfo.prompt4.value='0';


            document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/wip_inventory_intransit.rpt";

            /*if( success == true )
            {
                document.wipInventoryInfo.submit();
            }*/
        }
        else if ( cat == "discrepancy" )
        {
            document.wipInventoryInfo.prompt0.value = escape(document.wipInventoryInfo.process.value);
            document.wipInventoryInfo.prompt1.value = '0';
            if ( document.wipInventoryInfo.vendorName.value == "All Vendors" || document.wipInventoryInfo.vendorName.value == '' )
            {
                document.wipInventoryInfo.prompt2.value="0";
            }
            else
            {
                document.wipInventoryInfo.prompt2.value= document.wipInventoryInfo.vendorName.value;
            }
            document.wipInventoryInfo.prompt3.value = document.wipInventoryInfo.asOfDate.value;
            document.wipInventoryInfo.prompt4.value = document.wipInventoryInfo.search.value;
            document.wipInventoryInfo.prompt5.value = 'Crystal';
            document.wipInventoryInfo.prompt6.value = defaultPrompt;

            if( document.wipInventoryInfo.prompt0.value == '' )
                document.wipInventoryInfo.prompt0.value='0';
            else
                document.wipInventoryInfo.prompt0.value = escape(document.wipInventoryInfo.process.value);

            if( document.wipInventoryInfo.prompt3.value == '' || document.wipInventoryInfo.prompt3.value == today )
                document.wipInventoryInfo.prompt3.value='0';


            document.wipInventoryInfo.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/discrepancy.rpt";
            /*if( success == true )
            {
                document.wipInventoryInfo.submit();
            }*/
        }

        if( success == true )
        {
            if( fileType == 2 )
            {
                var prompt0 = document.wipInventoryInfo.prompt0.value;
                var prompt1 = document.wipInventoryInfo.prompt1.value;
                var prompt2 = document.wipInventoryInfo.prompt2.value;
                var prompt3 = document.wipInventoryInfo.prompt3.value;
                var prompt4 = document.wipInventoryInfo.prompt4.value;
                var prompt5 = document.wipInventoryInfo.prompt5.value;
                var prompt6 = document.wipInventoryInfo.prompt6.value;
                var prompt7 = document.wipInventoryInfo.prompt7.value;
                var prompt8 = document.wipInventoryInfo.prompt8.value;
                var prompt9 = document.wipInventoryInfo.prompt9.value;
                var prompt10 = document.wipInventoryInfo.prompt10.value;
                var prompt11 = document.wipInventoryInfo.prompt11.value;
                var prompt12 = cat;

                if ( cat == "discrepancy" )
                {
                    prompt5 = 'xlreport';
                }
                else if ( cat == "intransit" )
                {
                    prompt10 = 'xlreport';
                }
                else
                {
                    prompt8 = 'xlreport';
                }

                var url = '<%=chipTracContext%>/operationsDataDumpReports.do?action=wipInventoryInfoReport&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6 + '&prompt7=' + prompt7 + '&prompt8=' + prompt8+ '&prompt9=' + prompt9+ '&prompt10=' + prompt10+ '&prompt11=' + prompt11+ '&prompt12=' + prompt12;
                newWindow = window.open ( url, 'wipInventoryInfoReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');
            }
            else
            {
                if(document.wipInventoryInfo.action.indexOf("Operations/wip.rpt") != -1) {
                    document.wipInventoryInfo.action = "<%=chipTracContext%>/reports/wipReport.do?<%=Constants.REQUEST_PARAM_REPORT_NAME%>=operations/wip";
                } else if(document.wipInventoryInfo.action.indexOf("Operations/Wip_Inventory.rpt") != -1) {
                    document.wipInventoryInfo.action = "<%=chipTracContext%>/reports/wipReport.do?<%=Constants.REQUEST_PARAM_REPORT_NAME%>=operations/wip_inventory";
                }  else if(document.wipInventoryInfo.action.indexOf("Operations/Finished_Goods.rpt") != -1) {
                    document.wipInventoryInfo.action = "<%=chipTracContext%>/reports/wipReport.do?<%=Constants.REQUEST_PARAM_REPORT_NAME%>=operations/finished_goods";
                } else if(document.wipInventoryInfo.action.indexOf("Operations/discrepancy.rpt") != -1) {
                    document.wipInventoryInfo.action = "<%=chipTracContext%>/reports/wipReport.do?<%=Constants.REQUEST_PARAM_REPORT_NAME%>=<%=JasperReports.DISCRIPENCY_REPORT%>";
                } else if(document.wipInventoryInfo.action.indexOf("Operations/Fab_wip.rpt") != -1) {
                    document.wipInventoryInfo.action = "<%=chipTracContext%>/reports/wipReport.do?<%=Constants.REQUEST_PARAM_REPORT_NAME%>=<%=JasperReports.FAB_WIP_REPORT%>";
                } else if(document.wipInventoryInfo.action.indexOf("Operations/Assembly.rpt") != -1) {
                    document.wipInventoryInfo.action = "<%=chipTracContext%>/reports/wipReport.do?<%=Constants.REQUEST_PARAM_REPORT_NAME%>=<%=JasperReports.ASSEMBLY_WIP_REPORT%>";
                } else {
                    alert("---crystal rpt=>" + document.wipInventoryInfo.action);
                }
                document.wipInventoryInfo.submit();
            }
        }
    }
}

function getProductsForProcess()
{
	document.wipInventoryInfo.action="<%=chipTracContext%>/wipInventoryReport.do?action=inventoryInfoNew&processType="+ escape(document.wipInventoryInfo.process.value);
	document.wipInventoryInfo.submit();
}
function resetForm()
{
    document.wipInventoryInfo.reset();
    var len = document.wipInventoryInfo.reportType.length;
	for( var i = 0; i < len; i++ )
	{
		if(	document.wipInventoryInfo.reportType[i].checked )
		{
			var temp = 	document.wipInventoryInfo.reportType[i].value;
			if( temp == 'wip' || temp == 'inventory' || temp == 'all' || temp == 'allWithNonValue')
			{
				Enable();
			}
		}
	}
}

function checkSpecialChars()
{
    var pa=document.getElementById("errors");
    if ( ! notAllowedSpecialChars() )
    {
        pa.innerHTML = "<li>Search allows alphanumeric, - only</li>";
    }
    else
    {
        pa.innerHTML = "";
    }
}

function installNPViewer()
{
    //D:\chiptrac_spectra\jsp\includes\npviewer.exe
    var url = '<%=chipTracContext%>/jsp/includes/others/npviewer.exe';
                newWindow = window.open ( url, 'InstallNPViewer', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=50,height=50,resizable=no');
}

</script>

<TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type='text/css' rel='stylesheet'>
</HEAD>
<BODY bgColor='#ffffff' leftMargin='0' topMargin='0' marginheight="0" marginwidth="0" onload="javascript:Disab();">

<form name="wipInventoryInfo" method="post" <%--onSubmit="javascript:submitForm(1);"--%>>

<input type="hidden" name="prompt0">
<input type="hidden" name="prompt1">
<input type="hidden" name="prompt2">
<input type="hidden" name="prompt3">
<input type="hidden" name="prompt4">
<input type="hidden" name="prompt5">
<input type="hidden" name="prompt6">
<input type="hidden" name="prompt7">
<input type="hidden" name="prompt8">
<input type="hidden" name="prompt9">
<input type="hidden" name="prompt10">
<input type="hidden" name="prompt11">

<!-- Top Header Start-->
    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/header.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/extHeader.jsp" %>
    </logic:notEqual>
<!-- Top Header End-->
<TABLE cellSpacing=0 cellPadding=0 width="100%" border="0">
  <TBODY>
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<%--<!-- Side Navigation start -->
<%@ include file="/jsp/operations/reports_side_menu.jsp" %>
<!-- end of the side navigations -->--%>
<!-- Side Navigation start -->
    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/operations/reports_side_menu.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/sales/external_reports_menu.jsp" %>
    </logic:notEqual>
    <!-- end of the side navigations -->

<%--
<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
--%>
<%--
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
--%>
<TD valign="top" width="100%">

<!-- from here your body starts -->
<table border="0" width="100%" align="right" border="0">
    <tr><td colspan='7' align="center" class='NArialW'>
        WIP / Inventory Info
        </td>
    </tr>
    <tr><td colspan='7' align="left" class='NArialL'><font styleClass="NArialL" align="center" color='FF0000' id="errors"></font></td></tr>
	<tr><td colspan=7><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
    <tr><td colspan=7><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
    <tr>
        <td width="10%">&nbsp;</td>
        <td width="15%">&nbsp;</td>
		<td width="20%">&nbsp;</td>
        <td width="8%">&nbsp;</td>
        <td width="23%" valign="top"><font class="NArialL">Search Part Number</font></td>
        <td width="20%" valign="top"><font class="NArialL">
            <input type="text" name="search" size="20" class="txfield" maxlength="25"onkeypress="checkSpecialChars()"></font>&nbsp</td>
        <td width="12%">&nbsp;</td>
	</tr>
     <tr>
        <td width="10%">&nbsp;</td>
        <td width="15%" valign="top"><font class="NArialL">Process</font></td>
		<td width="20%" valign="top"><font class="NArialL">
			<%
                String processType = ""+request.getParameter("processType");
                String reportJs = request.getParameter("reportType");
                if( reportJs == null )
                {
                   reportJs = "wip";
                }
            %>
            <select size="1" name="process" class="txfield" onChange="getProductsForProcess()">
                <logic:iterate id="process" name="processList" type="org.apache.struts.util.LabelValueBean">
					<logic:notEqual name="process" value="null">
						<% if ( processType.equalsIgnoreCase( process.getValue() ) ) { %>
							<option value='<bean:write name="process" property="value"/>' selected >
						<% } else { %>
						    <option value='<bean:write name="process" property="value"/>' >
						<% } %>
						<bean:write name="process" property="label"/>
						</option>
					</logic:notEqual>
				</logic:iterate>
			</select>
			</font>
		</td>
		<td width="8%">&nbsp;</td>
		<td width="23%"  valign="top"><font class="NArialL">Product Name <br>(<bean:message key = "label.mfgPartNumber" />)</font></td>
		<td width="20%"  valign="top"><font class="NArialL">
      		<select size="5" name="productName" class="txfield" multiple="true">
				<option value="0" selected>All Products</option>
				<logic:iterate id="mktgPartNumberSelectList" name="mktgPartNumberSelectList" >
					<logic:notEqual name="mktgPartNumberSelectList" value="null">
						<option value="<bean:write name="mktgPartNumberSelectList" property="value"/>" >
							<bean:write name="mktgPartNumberSelectList" property="label"/>
						</option>
					</logic:notEqual>
				</logic:iterate>
			</select>
		</font></td>
		<td width="12%">&nbsp;
        </td>
	</tr>
    <tr><td colspan="7"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
    <tr>
        <td width="10%">&nbsp;</td>
        <td width="15%"  valign="top"><font class="NArialL"> Vendor </font></td>
		<td width="20%"  valign="top"><font class="NArialL">
            <select name="vendorName" class="txfield" >
		    <!--<option value="0">All Vendors</option>-->
			<logic:iterate id="vendorList" name="vendorList" >
				<logic:notEqual name="vendorList" value="null">
					<option value ="<bean:write name="vendorList" property="label"/>" >
						<bean:write name="vendorList" property="label"/>
					</option>
				</logic:notEqual>
			</logic:iterate>
		 </select>
         </font></td>
        <td width="8%">&nbsp;</td>
        <td width="23%" valign="top"><font class="NArialL">Lot Category</font></td>
        <td width="20%" valign="top"><font class="NArialL">
            <select name="category" class="txfield" >
			<logic:iterate id="categoryList" name="categoryList" >
				<logic:notEqual name="categoryList" value="null">
					<option value ="<bean:write name="categoryList" property="value"/>" >
						<bean:write name="categoryList" property="label"/>
					</option>
				</logic:notEqual>
			</logic:iterate>
		 </select>
        </font></td>
        <td width="12%">&nbsp;</td>
	</tr>
    <tr><td colspan=7><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
    <tr>
        <td width="10%">&nbsp;</td>
        <td width="15%"><font class="NArialL" >As of Date</font></td>
		<td width="20%"><font class="NArialL" >
            <input type="text" name="asOfDate" size="12" class="txfield" valign="top" maxlength="10">
            <a href="javascript:openCalendar(document.wipInventoryInfo.asOfDate)">
            <img onMouseOver="window.status='Click here to select date';return true" onMouseOut="window.status='';return true" border="0" align='center'
            src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
        </td>
		<td width="8%">&nbsp;</td>
        <td width="23%" valign="top"><font class="NArialL">Lot Status</font></td>
        <td width="20%" valign="top"><font class="NArialL">
            <select name="status" class="txfield" >
            <option value="0">All Status</option>
            <logic:iterate id="statusList" name="statusList" >
				<logic:notEqual name="statusList" value="null">
					<option value ="<bean:write name="statusList" property="value"/>" >
						<bean:write name="statusList" property="label"/>
					</option>
				</logic:notEqual>
			</logic:iterate>
		 </select>
        </font></td>
        <td width="12%">&nbsp;</td>
    </tr>
    <tr><td colspan=7><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
    <tr >
        <td width="10%">&nbsp;</td>
        <td colspan=6>
		<% String report = request.getParameter("reportType");
		   if( report == null )
		   {
			   report = "wip";
		   }
		%>
    	<input type="radio" name="reportType" value="inventory" <%= report.equalsIgnoreCase("inventory")?"checked":"&nbsp;"%> onclick = "javascript: Enable(); addOrRemoveOptionToProcessSelectNew('inventory','', 'true')">
    	<font class="NArialL">Inventory</font>&nbsp;&nbsp;&nbsp;&nbsp;
    	<input type="radio" name="reportType" value="wip" <%= report.equalsIgnoreCase("wip")?"checked":"&nbsp;"%> onclick ="javascript: Enable(); addOrRemoveOptionToProcessSelectNew('wip','', 'true')">
    	<font class="NArialL">WIP</font>&nbsp;&nbsp;&nbsp;&nbsp;
    	<input type="radio" name="reportType" value="all" <%= report.equalsIgnoreCase("all")?"checked":"&nbsp;"%> onclick ="javascript: Enable(); addOrRemoveOptionToProcessSelectNew('all','', 'true')">
    	<font class="NArialL">All</font>&nbsp;&nbsp;&nbsp;&nbsp;
         <input type="radio" name="reportType" value="allWithNonValue" <%= report.equalsIgnoreCase("allWithNonValue")?"checked":"&nbsp;"%> onclick ="javascript: Enable(); addOrRemoveOptionToProcessSelectNew('allWithNonValue','', 'true')">
    	<font class="NArialL">AllWithNonValue</font>&nbsp;&nbsp;&nbsp;&nbsp;
    	<input type="radio" name="reportType" value="finished" <%= report.equalsIgnoreCase("finished")?"checked":"&nbsp;"%> onclick ="/*javascript: Disab()*/addOrRemoveOptionToProcessSelectNew('finished','', 'true')">
		<font class="NArialL">Finished Goods</font>&nbsp;&nbsp;&nbsp;&nbsp;
    	<input type="radio" name="reportType" value="intransit" <%= report.equalsIgnoreCase("intransit")?"checked":"&nbsp;"%> onclick ="/*javascript: Disab()*/addOrRemoveOptionToProcessSelectNew('intransit','', 'true')">
    	<font class="NArialL">Lots InTransit</font>&nbsp;&nbsp;&nbsp;&nbsp;<br><br>
    	<input type="radio" name="reportType" value="discrepancy" <%= report.equalsIgnoreCase("discrepancy")?"checked":"&nbsp;"%> onclick ="/*javascript: Disab();*/addOrRemoveOptionToProcessSelectNew('discrepancy','', 'true')">
    	<font class="NArialL">Discrepancy</font>&nbsp;&nbsp;<br>
        <%--<input type="radio" name="reportType" value="holdlots" <%= report.equalsIgnoreCase("holdlots")?"checked":"&nbsp;"%> onclick ="javascript: Enable(); addOrRemoveOptionToProcessSelectNew('all','', 'true')">
    	<font class="NArialL">Hold Lots</font>&nbsp;&nbsp;
        <input type="radio" name="reportType" value="runninglots" <%= report.equalsIgnoreCase("runninglots")?"checked":"&nbsp;"%> onclick ="javascript: Enable(); addOrRemoveOptionToProcessSelectNew('all','', 'true')">
    	<font class="NArialL">Running Lots</font>&nbsp;&nbsp;&nbsp;&nbsp;<br><br>--%>
    </td></tr>
    <script>//addOrRemoveOptionToProcessSelectNew( '<%=reportJs%>' ,'<%=processType%>', '')</script>
    <%--</td></tr>--%>
    <tr><td colspan=7><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
    <tr>
        <td colspan=1>&nbsp;</td>
        <td colspan=4 align="center">
            <a href="javascript:submitForm(1)">
            <img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onMouseOver="window.status='Click to Generate Report';return true" onmouseout="window.status='';return true" title="Click here to Generate Report"/></a>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="javascript:resetForm();">
            <img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onMouseOver="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"/></a>
        </td>
        <td align="left" valign="top">
            <a class="NArialL" href="javascript:submitForm(2)" onMouseOver="window.status='Click here to Export to Excel';return true" onMouseOut="window.status='';return true" title='Click here to Export to Excel' >Export to Excel</a>
        </td>
        <td colspan=1>&nbsp;</td>
    </tr>
    <tr><td colspan=7><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
    <tr>
         <td colspan="7" align="center">
		 <table border="0" align="center">
         <%
	        ArrayList adaptorList = (ArrayList) request.getAttribute ("runInfoSelectList");
	        if (adaptorList == null) adaptorList = new ArrayList();
	        if(adaptorList.size()==0)
            {
        %>
            <font class="NArialL"><font color="FF0000"><li>Adaptors Last Running Information: Not found </font></font></table>
        <%
	        }
            else
            {
        %>
        <tr  bgcolor="#993333">
            <td width="20%" align="center" class="NArialL" ><font color="#FFFFFF">Adaptor Name</font></td>
            <td width="20%" align="center" class="NArialL"><font color="#FFFFFF">Last Updated Time</font></td>
            <td width="40%" align="center" class="NArialL" ><font color="#FFFFFF">File Name</font></td>
            <td width="20%" align="center" class="NArialL" ><font color="#FFFFFF">Latest Report Upload Time</font></td>
         </tr>

        <logic:iterate id="adaptorrunInfo" name="runInfoSelectList" indexId="iterateIdx">
        <% if( Integer.parseInt( iterateIdx.toString() ) % 2 == 0 ) { %>
		<tr bgcolor='#FFFFEE'>
		<%} else { %>
		<tr bgcolor='#DEE1E2'>
		<% } %>
           <td  width="20%" align="center"><font class="NArialL"> <bean:write name="adaptorrunInfo" property ="adaptorName"/></font></td>
           <td  width="20%" align="center"><font class="NArialL"> <bean:write name="adaptorrunInfo" property ="adaptorRunTime"/></font></td>
           <td  width="40%" align="center"><font class="NArialL"> <bean:write name="adaptorrunInfo" property ="fileName" filter = "false"/></font></td>
           <td  width="20%" align="center"><font class="NArialL"> <bean:write name="adaptorrunInfo" property ="uploadDate" filter = "false"/></font></td>
           </tr>
           </logic:iterate>
           </table> <% } %> </td></tr>
<tr>
        <td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/spacer.gif'>
        <td colspan=5 align="right" >
            <a class="NArialL" href="javascript:installNPViewer()" onMouseOver="window.status='Click here to install Activex Control for Reports';return true" onMouseOut="window.status='';return true" title='Click here to install Activex Control for Reports' >Click here to install Activex Control for Reports
            </a></td>
        <td colsapn=7><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=40></td>
    </tr>
<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
</table>


<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</form>
</BODY>
</HTML>
<%--
<% } catch(Exception e){e.printStackTrace();} %>--%>
